package com.itguigu.rabbitmq.eight;

import com.itguigu.rabbitmq.utils.RabbitMqutil;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;

/**
 * @Date 2021/7/19 10:01
 * @Created by wangle
 * @Description
 */
public class Consumer02 {
    public static final String exchangeName = "normal_exchange";
    public static final String exchangeName2 = "dead_exchange";
    public static final String queueName = "normal_queue";
    public static final String queueName2 = "dead_queue";

    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitMqutil.getChannel();
        System.out.println("02等待接收消息");
        //声明 接受消息
        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("consumer2接受的消息是：" + new String(message.getBody()));


        };

        //取消消息时的回调
        CancelCallback cancelCallback = (consumerTag) -> {

            System.out.println("消息消费被中断");
        };
        channel.basicConsume(queueName2, true, deliverCallback, cancelCallback);

    }


}
